<template>
  <transition name="slide-fade">
    <div class="toast" v-show="visible">
      {{ content }}
    </div>
  </transition>
</template>

<script>
export default {
  name: 'Toast',
  data () {
    return {
      visible: false,
      content: 'sssscdasnajksbcsdbcjsdlknck'
    }
  },
  methods: {
    setContent (msg) {
      this.content = msg
    },
    close () {
      this.visible = false
      this.destroyElement()
    },
    destroyElement () {
      this.$el.removeEventListener('transitionend', this.destroyElement)
      this.$destroy(true)
      this.$el.parentNode.removeChild(this.$el)
    }
  }
}
</script>

<style lang="less">
.toast {
    width: fit-content;
    height: fit-content;
    padding: 8px 14px;
    font-size: 14px;
    border-radius: 7px;
    color: #FFF;
    background-color: rgba(0, 0, 0, 0.6);
    position: fixed;
    top: 30vh;
    left: 0;
    right: 0;
    margin: auto;
}
</style>
